package com.newmacys.user;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.context.ApplicationContext;

import com.newmacys.user.bean.User;

/**
 * Servlet implementation class ViewUserManager
 */
public class ViewUserManager extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public ViewUserManager() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//processRequest(request, response, null);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//processRequest(request, response, null);
	}

	public static void processRequest(HttpServletRequest request, HttpServletResponse response, ApplicationContext appContext) throws ServletException, IOException {

		User userBean = (User) appContext.getBean("UserData");
		request.setAttribute("User", userBean);
		System.out.println("[Stpring Manager] UserName=" + userBean.getName());

		RequestDispatcher dispatcher = request.getRequestDispatcher("/viewUser.jsp");
		dispatcher.include(request, response);
		
	}

}
